package org.nanfang.Yield.Interr;

public class InterrUpted extends Thread{
    public InterrUpted(){
        super();
    }
    public InterrUpted(String name){
        super(name);
    }
    @Override
    public void run() {
        System.out.println("执行线程相关的程序");
        while (true){
            boolean flag = Thread.currentThread().isInterrupted();
            if (flag==false){
                System.out.println("再继续执行一些");
                break;
            }
            System.out.println("非阻断线程"+ flag);

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                System.out.println("睡眠被中断的状态"+ Thread.currentThread().isInterrupted());

//                throw new RuntimeException(e);
                Thread.currentThread().interrupt();
            }
        }
    }
}
